import React from 'react';
import './index.less'

class Login extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            username: '',
            password: '',
        }
    }

    login = () => {
        setTimeout(() => {
            this.props.history.push('/home');
        }, 1000);
    }

    changeMsg = (name, e) => {
        this.setState({
            [name]: e.target.value
        })
    }

    render() {
        return (
            <div className="login">
                <div className="login-div">
                    <span className="login-span">用户名：</span>
                    <input type="text" placeholder="请输入用户名" className="login-input" value={this.state.username}
                    onChange={this.changeMsg.bind(this, 'username')}></input>
                </div>
                <div className="login-div">
                    <span className="login-span">密码：</span>
                    <input type="text" placeholder="请输入密码" className="login-input" value={this.state.password}
                    onChange={this.changeMsg.bind(this, 'password')}></input>
                </div>
                <button className="login-btn" onClick={this.login}>登陆</button>
            </div>
        )
    }
}

export default Login;